////////////////////////////////////////////////////////////////////////////////
//
// Licensed under the MIT License
//
// Copyright (c) 2008 Chris Colinsky
// All Rights Reserved
//
// version	0.5
// http://code.google.com/p/sugarcookie/
// http://code.google.com/p/sugarcookie/wiki/License
//
////////////////////////////////////////////////////////////////////////////////

var agent =  navigator.userAgent.toLowerCase();
var sf = (agent.indexOf("safari") > 0)? true:false;
var ff  = (agent.indexOf("firefox") > 0)? true:false;
var ie = (agent.indexOf("msie") > 0)? true:false;
var mac = (agent.indexOf("mac") > 0)? true:false;
var droid = (agent.indexOf("android") > 0)? true:false;
var iphone = (agent.indexOf("iphone") > 0)? true:false;
var webos = (agent.indexOf("webos") > 0)? true:false;

var minWidth = "1";
var minHeight = "1";

function init() {
	manageLayout();
	window.onresize = doResize;
}
window.onload = init;

var timeoutID;
function doResize() {
	clearTimeout(timeoutID);
	timeoutID = setTimeout("manageLayout()",100);
}

function manageLayout(){
	if (sf || ff) {
		if (window.innerWidth<Number(minWidth)) {
			document.getElementById("page_container").style.width = minWidth+"px";
		} else {
			document.getElementById("page_container").style.width = "100%";
		}
		if (window.innerHeight<Number(minHeight)) {
			document.getElementById("page_container").style.height = minHeight+"px";
		} else {
			document.getElementById("page_container").style.height = "100%";
		}
	} else if (ie) {
		if (document.body.clientWidth<Number(minWidth)) {
			document.getElementById("page_container").style.width = minWidth;
		} else {
			document.getElementById("page_container").style.width = "100%";
		}
		if (document.body.clientHeight<Number(minHeight)) {
			document.getElementById("page_container").style.height = minHeight;
		} else {
			document.getElementById("page_container").style.height = "100%";
		}
	}
}